<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>"> 
    <title>修改密码界面</title>  
    <link rel="stylesheet" href="<%=path %>/plugins/layui/css/layui.css" media="all">
  </head>

  <script src="<%=path %>/plugins/layui/layui.js"></script>
  
  <body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>填写账户密码界面</legend>
</fieldset>
<form class="layui-form layui-form-pane" id="TreatForm" lay-filter="example" action="呵呵">
<div class="layui-container">  
  <div class="layui-row">
    <div class="layui-col-md12 layui-col-md-offset2">
	  <div class="layui-form-item">
	    <label class="layui-form-label">旧密码</label>
	    <div class="layui-input-inline">
	      <input type="hidden" id="userId" name="userId" value="${user.userId }"/>
	      <input style="width:500px;" type="text" name="userPassword"  placeholder="请输入" autocomplete="off"  lay-verify="userPassword" class="layui-input" >
	    </div>
	  </div>
    </div>
    <div class="layui-col-md12 layui-col-md-offset2">
	  <div class="layui-form-item">
	    <label class="layui-form-label">新密码</label>
	    <div class="layui-input-inline">
	      <input style="width:500px;" id="L_pass" type="password" name="newUserPassword"  placeholder="请输入" autocomplete="off"  required  lay-verify="newUserPassword" class="layui-input" >
	    </div>
	  </div>
    </div>
    <div class="layui-col-md12 layui-col-md-offset2">
	  <div class="layui-form-item">
	    <label class="layui-form-label">重复密码</label>
	    <div class="layui-input-inline">
	      <input style="width:500px;" type="password" name="repass"  id="L_repass" placeholder="请输入" autocomplete="off"  required   lay-verify="repass" class="layui-input" >
	    </div>
	  </div>
    </div>
    <div class="layui-col-md12">
		 <div class="layui-form-item" align="center">
		   <button class="layui-btn" lay-submit="" lay-filter="submit">确认修改</button>
		 </div>
    </div>
  </div>
</div>

  

  

  

  
</form>
</body>
  
<script>
layui.use(['form', 'layedit', 'laydate', 'jquery'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate
  ,$ = layui.jquery;
 
  form.verify({ 
    userPassword:[/(.+){6,12}$/, '密码必须6到12位']
	,newUserPassword: [/(.+){6,12}$/, '密码必须6到12位']
	,repass: function(value){
		var repassvalue = $('#L_pass').val();
		if(value != repassvalue){
			return '两次输入的密码不一致!';
	    }
	}
   });
   
  //监听提交
  form.on('submit(submit)', function(data){
	$.ajax({
		url: '<%=path%>/biz/SysUser_editPassword.action',
		type: 'GET',
		data: $('#TreatForm').serialize(),
		dataType: 'json',
		success: function(data){
			var json = eval("("+data+")");
			//添加成功
			if(json.isSucceed){
				layer.open({
			        content: '<div style="padding: 20px 100px;">修改成功~</div>'
			        ,btn: '朕知道了'
			        ,btnAlign: 'c' //按钮居中
			        ,shade: 0 //不显示遮罩
			        ,yes: function(){
			        	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引 
						parent.layer.close(index);//再执行关闭当前iframe页面  
						parent.location.reload();//刷新父页面
			        }
			      });
			}else{
				message("修改失败~旧密码不正确");
				//关闭当前iframe弹出层
				parent.layer.close();
			}
		},
		error: function(data){
			layer.msg("请求失败");
		}
	});
    return false;//阻止表单跳转
  }); 
  
  //信息提示弹出层
  function message(data){
      layer.open({
        content: '<div style="padding: 20px 100px;">'+ data +'</div>'
        ,btn: '朕知道啦'
        ,btnAlign: 'c' //按钮居中
        ,shade: 0 //不显示遮罩
        ,yes: function(){
          layer.closeAll();
        }
      }); 
  }

  $('#layerDemo .layui-btn').on('click', function(){
    var othis = $(this), method = othis.data('method');
    active[method] ? active[method].call(this, othis) : '';
  });
  
});
</script>
</html>
